package cn.geodata.dataview.action;

import java.util.Date;

import cn.geodata.dataview.Fire;
import cn.geodata.dataview.FireFactory;
import cn.geodata.dataview.util.Util;
import cn.geodata.service.user.UserInstance;

import com.vividsolutions.jts.geom.Point;

public class ImageView {
	private String id;
	private int path;
	private int row;
	private Date date;
	private String dir;
	private String source;
	private String sensor;
	private String note;
	private float cloud;
	private String quality;
	private double x;
	private double y;
	
	public float getCloud() {
		return cloud;
	}
	public String getQuality() {
		return quality;
	}
	public int getPath() {
		return path;
	}
	public int getRow() {
		return row;
	}
	public Date getDate() {
		return this.date;
	}
	public String getDir() {
		return dir;
	}
	public String getSource() {
		return source;
	}
	public String getSensor() {
		return sensor;
	}
	public String getNote() {
		return note;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getId() {
		return this.id;
	}
	
	public String execute() throws Exception {
		if(this.id == null){
			throw new NullPointerException("Not found image parameter");
		}
		
		Fire _data = (Fire) (new FireFactory()).load(this.id, new UserInstance("dataview", "127.0.0.1"));
		
		this.path = _data.getPath();
		this.row = _data.getRow();
		this.date = _data.getDate();
		this.dir = _data.getDir();
		this.sensor = _data.getSensor();
		this.source = _data.getSource();
		this.note = _data.getNote();
		this.cloud = _data.getCloud();
		this.quality = _data.getQuality();

		Point _pt = Util.locatePathRow(this.path, this.row).getDefaultGeometry().getCentroid();
		this.x = _pt.getX();
		this.y = _pt.getY();

		return "success";
	}
	
	public double getX() {
		return x;
	}
	public double getY() {
		return y;
	}
}
